{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## scikit-learn中的多项式回归和Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "poly = PolynomialFeatures(degree=2)\n",
    "poly.fit(X)\n",
    "X2 = poly.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 3)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 0.14960154],\n",
       "       [ 0.49319423],\n",
       "       [-0.87176575],\n",
       "       [-1.33024477],\n",
       "       [ 0.47383199]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.        ,  0.14960154,  0.02238062],\n",
       "       [ 1.        ,  0.49319423,  0.24324055],\n",
       "       [ 1.        , -0.87176575,  0.75997552],\n",
       "       [ 1.        , -1.33024477,  1.76955114],\n",
       "       [ 1.        ,  0.47383199,  0.22451675]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "lin_reg2 = LinearRegression()\n",
    "lin_reg2.fit(X2, y)\n",
    "y_predict2 = lin_reg2.predict(X2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VNX5x/HPIQQJuESFqoRdEUTZJIoW9w2KiBGtS3G3\nUm1daJUK4gL+VFRsrdpaG8GqRUEExF1UcEORGkCLirgjBhFUQGUTwvn9cTKQhJnMemfuvfN9v17z\nItzMzD0zSZ459znPOcdYaxERkeBrkOsGiIhIZiigi4iEhAK6iEhIKKCLiISEArqISEgooIuIhIQC\nuohISCigi4iEhAK6iEhINMzmyZo1a2bbtm2bzVOKiATe3Llzv7XWNo93v6wG9LZt21JRUZHNU4qI\nBJ4xZnEi91PKRUQkJBTQRURCQgFdRCQkFNBFREJCAV1EJCSyWuUiIpJPps2vZMz0RSxdtY4WxUUM\n7dORsh4lnp1PAV1ExAPT5lcyfOoC1m2sAqBy1TqGT10A4FlQV8pFRMQDY6Yv2hLMI9ZtrGLM9EWe\nnVMBXUTEA0tXrUvqeCYooIuIeKBFcVFSxzNBAV1ExAND+3SkqLCg1rGiwgKG9uno2Tk1KCoi4oHI\nwKeqXEREQqCsR4mnAbwupVxEREJCAV1EJCQU0EVEQkIBXUQkJBTQRURCQgFdRCQkFNBFREJCAV1E\nJCQU0EVEQkIBXU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iQDW2hHW2lbAw8AluW1t/eK9lur7jAA24V6PbyXyWkS8YIzZHpgC\nDKlzlR4o1toqa2133NX4gcYYz1JiKW9Bl2nW2mMSvOvDwLPA9R42Jy3xXosx5lygP3C09fkgRhI/\nlyDSRuc+VZ1vngI8bK2dmuv2ZIK1dpUx5mWgL+DJ4LVveuj1McZ0qPHfE4EPc9WWdBlj+gJ/BgZY\na9fmuj15Thud+1D1QOI4YKG19q+5bk86jDHNI5Vsxpgi3AC8Z/ErKFUuU4COuIqKxcBF1tpA9qSM\nMZ8A2wHfVR96K8AVOycBdwPNgVXAO9baPrltVXKMMf2Av7F1o/ObctyklBhjJgBH4Fb1+wa43lo7\nLqeNSpEx5hDgdWAB7m8e4Gpr7bO5a1VqjDFdgQdxv18NgEnW2hs8O18QArqIiMQXiJSLiIjEp4Au\nIhISCugiIiGhgC4iEhIK6CIiIaGALiISEgroIiIhoYAuIhIS/w/lMR6IZTMyOAAAAABJRU5ErkJg\ngg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10ecc2438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict2[np.argsort(x)], color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  0.9460157 ,  0.50420543])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.1536054095953823"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.intercept_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 关于PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X = np.arange(1, 11).reshape(-1, 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1,  2],\n",
       "       [ 3,  4],\n",
       "       [ 5,  6],\n",
       "       [ 7,  8],\n",
       "       [ 9, 10]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "poly = PolynomialFeatures(degree=2)\n",
    "poly.fit(X)\n",
    "X2 = poly.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5, 6)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[   1.,    1.,    2.,    1.,    2.,    4.],\n",
       "       [   1.,    3.,    4.,    9.,   12.,   16.],\n",
       "       [   1.,    5.,    6.,   25.,   30.,   36.],\n",
       "       [   1.,    7.,    8.,   49.,   56.,   64.],\n",
       "       [   1.,    9.,   10.,   81.,   90.,  100.]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, 100)\n",
    "\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "poly_reg = Pipeline([\n",
    "    (\"poly\", PolynomialFeatures(degree=2)),\n",
    "    (\"std_scaler\", StandardScaler()),\n",
    "    (\"lin_reg\", LinearRegression())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "poly_reg.fit(X, y)\n",
    "y_predict = poly_reg.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X2clXP+x/HXt2nKiEy7cjeF3GxENJqslbXEyt0yskiy\n7rP2F7mLWFastojFsqIlIrIoYYu0ylK72UpId7RuyrgpNEiTmWm+vz++M5mZzs11zrmuc67rzPv5\neMxDc5xzne9V1/lc3/P5fr7fr7HWIiIi0dEq1w0QEZHUKHCLiESMAreISMQocIuIRIwCt4hIxChw\ni4hEjAK3iEjEKHCLiESMAreISMS0DuKg2267rd11112DOLSISF5asGDBF9bajl6eG0jg3nXXXZk/\nf34QhxYRyUvGmI+8PlepEhGRiFHgFhGJGAVuEZGIUeAWEYkYBW4RkYhR4BYRiZhAygFFRKJsysIK\nRk9fzieVVexUXMTQvl0pLy3JdbM2UeAWEWlkysIKrpm8iKqajQBUVFZxzeRFAKEJ3kqViIg0Mnr6\n8k1Bu0FVzUZGT1+e+IWffx5gq5pS4BYRaeSTyqqUHgegogL22gtuvz2gVjWlwC0i0shOxUUpPY61\nMGgQfP89nHBCgC37gQK3iEgjQ/t2paiwoMljRYUFDO3bNfYLHn4Ypk2DUaNgzz2DbyAanBQRaaJh\nANJTVcmqVXDppfCLX8DgwVlrowK3iEgz5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BOstetz3Z4WbB6wpzGmizGmDdAfeC7HbWrx6gf0HgSWWmv/nOv2ZMIY07GhaswY\nU4QbCA8sdoWxqmQS0BVXwfAR8FtrbSR7R8aYFUBb4Mv6h+ZGuELmJOBuoCNQCbxpre2b21Z5Z4w5\nFrgTKADGWWtH5LhJaTPGTAQOw61C9zlwg7X2wZw2Kg3GmEOA14BFuM87wLXW2mm5a1V6jDH7AeNx\n11cr4Elr7U2BvV/YAreIiCQWulSJiIgkpsAtIhIxCtwiIhGjwC0iEjEK3CIiEaPALSISMQrcIiIR\no8AtIhIx/w9R7kW0XEkZagAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10e751908>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict[np.argsort(x)], color='r')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
